<script>
$(document).ready(function(){
		$("#more_province,  #hide_left_province").css("color", "red");
		$("#more_province, #hide_left_province").css("cursor", "pointer");
		$("#left_province,  #hide_left_province").hide();
		
		$("#more_province").click(function(){
			$("#left_province").slideDown();
			$("#more_province").hide();
			$("#hide_left_province").show(2000);
		});
		
		$("#hide_left_province").click(function(){
			$("#left_province").slideUp();
			$("#more_province").show(1000);	
			$("#hide_left_province").hide();		
		});
});
</script>
<style>
#more_province{}
</style>
<?php
	$numbertop = mysql_query("SELECT * FROM ".Tblrefcode::tblname." WHERE ".Tblrefcode::name." = 'top_province' AND ".Tblrefcode::type." = 'global_setting' LIMIT 1");
	$top = mysql_fetch_object($numbertop);
	$query = mysql_query("SELECT ".Tblproduct::province_id." , COUNT(*) AS province_id FROM ".Tblproduct::tblproduct." GROUP BY ".Tblproduct::province_id." ORDER BY province_id DESC lIMIT " . $top->{Tblrefcode::value}. " ");
	
	$query_after5province = mysql_query("SELECT ".Tblproduct::province_id." , COUNT(*) AS province_id FROM ".Tblproduct::tblproduct." GROUP BY ".Tblproduct::province_id." ORDER BY province_id DESC lIMIT " .$top->{Tblrefcode::value}." , 25");
		echo '<p>';
		if($query){
			while($province_list = mysql_fetch_assoc($query)){
				$pro_id = $province_list['pr_province_id'];
				$province_query = mysql_query("SELECT * FROM  ".Tblprovince::tblprovince." WHERE ".Tblprovince::id." = ".$pro_id." ");
				if($province_query){
					while($province_name = mysql_fetch_assoc($province_query)){
					echo '<a href="product/?searchby=1&province='.$pro_id.'" >'.$province_name[Tblprovince::name].'</a>&nbsp;(<span style="color:#F89406;">'.$province_list['province_id'].'</span>)<br />';
					}
				}
			}
		}
		echo '</p>';
		if(mysql_num_rows($query) >= $top->{Tblrefcode::value}){
				echo '<b id="more_province" >More provinves...</b>';
			}
		
		echo '<p id="left_province">';
		while($query_after = mysql_fetch_assoc($query_after5province)){
			$pro_id = $query_after['pr_province_id'];
			@$province_query = mysql_query("SELECT * FROM  ".Tblprovince::tblprovince." WHERE ".Tblprovince::id." = ".@$pro_id." ");
			while(@$province_name = mysql_fetch_assoc(@$province_query)){
				echo '<a href="product/?searchby=1&province='.@$pro_id.'" >'.@$province_name[Tblprovince::name].'</a>&nbsp;(<span style="color:#F89406;">'.$query_after['province_id'].'</span>)<br />';
			}
		}
		echo '</p>';
	echo '<b id="hide_left_province" style="color:red;">Show top 5 provinces</b>';
?>